package com.company.netease;

import java.util.Scanner;

public class Main3 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        byte t = sc.nextByte();
        while (t-- > 0){
            int n = sc.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n ; i++) {
                arr[i] = sc.nextInt();
            }
            int res = getLeastThingsValue(n,arr);
            System.out.println(res);

        }

    }

    // 最少
    private static int getLeastThingsValue(int n, int[] arr) {
        if(n == 1){
            return arr[0];
        }
        if(n == 2){
            if(arr[0] == arr[1]){
                return 0;
            }else{
                return arr[1] + arr[2];
            }
        }

        return 0;
    }
}
